package com.ys.obj
{
	import com.ys.util.Const;
	
	import flash.display.DisplayObject;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	public class Text extends TextField
	{
		
		
		public function Text()
		{
			setDefaults();
		}
		
		private function setDefaults():void
		{
			var fmt:TextFormat = Const.DEFAULT_FORMAT;
			defaultTextFormat = fmt;
			embedFonts = true;
			antiAliasType = 'advanced';
			selectable = false;
			textColor = Const.FONT_COLOR;
			
		}
		
		public function setProperties(size:int=12, color:uint=0, multiline:Boolean=false):void
		{
			var fmt:TextFormat = defaultTextFormat;
			fmt.size = size;
			defaultTextFormat = fmt;
			textColor = color;
			if (multiline)
			{
				wordWrap = true;
				multiline = true;
			}
		}
		
		public function centerPosition(displayObject:DisplayObject=null):void
		{
			autoSize = 'center';
			x = -width/2;
			y = -height/2;
			
			if (displayObject)
			{
				x = x + displayObject.width/2;
				y = y + displayObject.height/2;
			}
			
		}

	}
}